#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>
#include    <QPushButton>
#include    <QMenuBar>
#include    <QMenu>
#include    <QAction>
#include    <QDebug>
#include    "qtabout.h"
#include  <QHBoxLayout>
#include <QVBoxLayout>
#include <QPushButton>
#include <QTextBrowser>
#include  <QGridLayout>
#include  <QComboBox>
#include    <QTime>
#include    <QString>
#include   <QTimer>
#include    <QtSerialPort/QSerialPort>
#include    <QtSerialPort/QtSerialPort>
#include    <common.h>
#include    <QThread>
#include    "protocol.h"
#include    "qtset.h"
class MainWindow : public QMainWindow
{
    Q_OBJECT
public slots:
    void  createAbout();
    void  updatesystime();
    void  slot_serial_open();
    void  slot_serial_close();
    void  slot_sendokbutton();
    void serial_read();
    void  slot_serial_clock();  //串口超时槽。
    void slot_create_set();  //set 页面的槽函数。
public:
    MainWindow(QWidget *parent = 0);
    ~MainWindow();
    void creatMenu();
    void creatAction();
    void creatMainPage();
    void  creatSysClock();  //创建系统定时器。
    void general_op();//设置一般的操作。
    void serial_write(const char * data);
    //file menu
    QMenu     *menu_file;

    QAction     *newAct;
    QAction    *openAct;
    QAction     *saveAct;
    QAction     *printAct;
    //set menu
    QMenu       *menu_set;
    qtset          *qtset_form;
    QAction      *setAction;
    //help menu
     QMenu     *menu_help;
    QAction     *aboutAct;
    qtabout       *about;
    //testmenu
    QMenu    *menu_test;
    QAction    *menu_act;


  //
  QWidget *widget;
  QLabel    *serial_port;
  QLabel    *serial_baud;
  QLabel    *serial_parity;
  QLabel    *serial_data;
  QLabel    *serial_stop;
  QLabel    *systime;
   QComboBox   * serial_port_com;
   QComboBox    *serial_baud_com;
   QComboBox    *serial_parity_com;
   QComboBox    *serial_data_com;
   QComboBox    *serial_stop_com;
   QPushButton  *serial_open;
   QPushButton  *serial_close;
 QTextBrowser  *frameBrowser;
 QTextEdit         *sendFrameEdit;
 QLabel             *serial_intput_state;
 QPushButton   * sendokbutton;
 QHBoxLayout  *mainLayout;
 QVBoxLayout  *configLayout;
 QGridLayout  *configLayout_serial;
 QVBoxLayout  *sysconfig;
 QGridLayout  *frame_text_RxTx;
 QTime  *systimer;
 QTimer *sysclock;   //系统定时器。
 QTimer  *serial_clock;  //串口超时定时器。
 QSerialPort  *serial;//打开的系统串口
 char   serial_send_buf[2048];

 common   common;
 protocol   *protocol_thread;
};

#endif // MAINWINDOW_H
